import 'package:flutter/material.dart';
import 'package:flutter_yres/pages/user/order/jyz_order_list_page.dart';

class JYZOrderPage extends StatefulWidget {
  JYZOrderPage({Key key}) : super(key: key);

  @override
  _JYZOrderPageState createState() => _JYZOrderPageState();
}

class _JYZOrderPageState extends State<JYZOrderPage> {
  TabController _tabController;

 List tabs = [{'name':'全部','status':''},{'name':'已支付','status':'1'},{'name':'退款','status':'5'}];

  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
      length: tabs.length,
      child:  Scaffold(
        appBar:  AppBar(
          backgroundColor: Colors.red,
          title: Text('加油订单'),
          bottom:  TabBar(
            isScrollable: true,
            tabs: tabs.map((item) {
              return _tabsBuilder(context, item);
            }).toList(),
            controller: _tabController,
            onTap: (index) {
              print(tabs[index].pdd_id);
            },
          ),
        ),
        body: TabBarView(
          children: tabs.map<Widget>((item) {
            print(item['status']);
              return JYZOrderListPage(status:item['status']);
          }).toList(),
        ),
      )
    );
  }
    Widget _tabsBuilder(BuildContext context, item) {
    return Tab(text: item['name']);
  }
}